CREATE TABLE [dbo].[GRNDetails]
(
[GRNDetailId] [bigint] NOT NULL IDENTITY(1, 1),
[GRNId] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DrugId] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Quantity] [int] NOT NULL,
[POQuantity] [int] NOT NULL,
[UnitPrice] [money] NOT NULL,
[ExpDate] [datetime] NULL,
[BatchLot] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Remark] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OpeningBalance] [int] NOT NULL CONSTRAINT [DF_GRNDetails_OpeningBalance] DEFAULT ((0)),
[OpeningAmount] [decimal] (16, 0) NOT NULL CONSTRAINT [DF_GRNDetails_OpeningAmount] DEFAULT ((0)),
[IsComplete] [bit] NOT NULL CONSTRAINT [DF_GRNDetails_IsComplete] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[GRNDetails] ADD CONSTRAINT [PK_GRNDetails] PRIMARY KEY CLUSTERED  ([GRNDetailId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[GRNDetails] ADD CONSTRAINT [FK_GRNDetails_DrugDispo] FOREIGN KEY ([DrugId]) REFERENCES [dbo].[DrugDispo] ([DrugId])
GO
ALTER TABLE [dbo].[GRNDetails] ADD CONSTRAINT [FK_GRNDetails_GRN2] FOREIGN KEY ([GRNId]) REFERENCES [dbo].[GRN] ([GRNId])
GO
